package com.cloud.cloudorder.order.config.rabbitmq;

import com.cloud.common.constant.RabbitmqOrderConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author : Luojie
 * @CreateTime : 2019/9/3
 * @Description :
 **/
@Configuration
public class DeadRabbitConfig {
 
    //队列 起名：OrderDirectQueue
    @Bean
    public Queue OrderDeadQueue() {
        return new Queue(RabbitmqOrderConstants.ORDER_DEAD_QUEUE,true);
    }
 
    //Direct交换机 起名：OrderDirectExchange
    @Bean
    DirectExchange OrderDeadExchange() {
        return new DirectExchange(RabbitmqOrderConstants.ORDER_DEAD_EXCHANGE,true,false);
    }
 
    //绑定  将队列和交换机绑定, 并设置用于匹配键：OrderDirectRouting
    @Bean
    Binding bindingDead() {
        return BindingBuilder.bind(OrderDeadQueue()).to(OrderDeadExchange()).with(RabbitmqOrderConstants.ORDER_DEAD_ROUTING);
    }
}